package com.chen.core.utils;

import org.jasypt.util.text.AES256TextEncryptor;

/**
 * 生成配置文件密文
 * @author chen
 */
public class ConfigureEncryptionUtil {

    /**
     * 加密配置文件文本
     *
     * @param text 待加密文本
     * @return 加密后的文本
     */
    public static String textEncrypt(String text) {
        AES256TextEncryptor textEncryptor = new AES256TextEncryptor();

        /*配置文件中配置的password*/
        textEncryptor.setPassword("EWRREWRERWECFDGT");

        return textEncryptor.encrypt(text);
    }

    public static void main(String[] args) {
        String name = ConfigureEncryptionUtil.textEncrypt("root");
        String password = ConfigureEncryptionUtil.textEncrypt("123456");

        /*将加密的文本写到配置文件中*/
        System.out.println("name=" + name);
        System.out.println("password=" + password);
    }
}
